package com.eastfair.point.controller;

import com.eastfair.point.dao.TestCollectionDao;
import com.eastfair.point.entity.TestCollection;

import java.util.Date;

import com.eastfair.core.base.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 * 前端控制器
 * 用户账户信息
 * </p>
 *
 * @author ligang
 * @date 2021-08-10
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/test")
@Api(value = "test", tags = "用户账户信息")
public class TestCollectionController {

    @Autowired
    private KafkaTemplate<String,Object> kafkaTemplate;

    @Autowired
    TestCollectionDao testCollectionDao;
    @RequestMapping(value = "/add", method = RequestMethod.GET)
    @ResponseBody
    public R add() {
        TestCollection testCollection = new TestCollection();
        testCollection.setBookId("111111111111111");
        testCollection.setSchoolId("999999999999");
        testCollection.setDate(new Date());
        testCollectionDao.add(testCollection);
        return R.success(testCollection);
    }




    @ApiOperation(value = "kafka provider", notes = "kafka provider")
    @GetMapping("/message/send")
    public boolean send(@RequestParam String message){
        kafkaTemplate.send("test_ef_biz_point_log",message);
        return true;
    }



}
